package cn.lil.servlet;

import cn.lil.dao.BearingDao;
import cn.lil.model.Bearing;
import cn.lil.service.BearingService;
import jakarta.servlet.*;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.*;

import java.io.IOException;
import java.sql.SQLException;

@WebServlet(name = "BearingDetailServlet", value = "/BearingDetailServlet")
public class BearingDetailServlet extends HttpServlet {
    BearingService bearingService = new BearingService();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        int id = Integer.parseInt(request.getParameter("id"));
        Bearing bearing = null;
        try {
            bearing = bearingService.selectBearingById(id);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        request.getSession().setAttribute("bearing", bearing);
        request.getRequestDispatcher("/details.jsp").forward(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
